#include <UnitTest++.h>
#include <Utility/TextProgress.hpp>
#include <Utility/Timer.hpp>
#include <Math/Vector3.hpp>
#include <Utility/Tools.hpp>
#include <Math/Vector4.hpp>

using namespace zzz;
using namespace std;

SUITE(TOOLSTEST)
{
  TEST(TEXTPROGRESS)
  {
//     TextProgress tp("Text Progress %s->%b %n = %p",122,0);
//     tp.ShowProgressBegin();
//     for (int i=0; i<123; i++)
//     {
//       tp.ShowProgress(i);
//     }
//     tp.ShowProgressEnd();
  }

  TEST(TimerTest)
  {
    Timer t;
    int n=0;
    t.Sleep(100);
    double thistime=t.Elapsed();
    t.Pause();
    t.Sleep(100);
    CHECK_EQUAL(thistime,t.Elapsed());
    t.Resume();
    t.Sleep(100);
    CHECK(thistime<t.Elapsed());
  }

  TEST(SafeEqualTest)
  {
    Vector3f a(1,2,3), b(1,2,3), c(1,3,2);
    CHECK(SafeEqual(a.begin(),a.end(), b.begin(),b.end()));
    CHECK(!SafeEqual(a.begin(),a.end(), c.begin(),c.end()));
    Vector4f d(1,2,3,4);
    CHECK(SafeEqual(a.begin(),a.end(), d.begin(),d.end()));
    CHECK(!SafeEqual(d.begin(),d.end(), a.begin(),a.end()));
  }

  TEST(BitTest)
  {
    int BIT1=1;
    int BIT2=1<<2;
    int BIT3=1<<10;
    int a = BIT2;
    SetBit(a, BIT1);
    CHECK_EQUAL(BIT1+BIT2,a);
    CHECK(CheckBit(a, BIT1));
    CHECK(CheckBit(a, BIT2));
    CHECK(!CheckBit(a, BIT3));
    ClearBit(a, BIT2);
    CHECK(!CheckBit(a, BIT2));
  }

}